package com.lepu.flutterdemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.lepu.flutterdemo.boost.BoostTestActivity
import com.lepu.flutterdemo.tab.TabActivity
import io.flutter.embedding.android.FlutterActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        btnMain.setOnClickListener {
            Intent(this, TabActivity::class.java).also {
                startActivity(it)
            }
        }
        btnToFlutterPage.setOnClickListener {
            //跳转默认界面
//            startActivity(
//                FlutterActivity.createDefaultIntent(this)
//            )
            //跳转指定路由界面
//            FlutterActivity.withNewEngine()
//                .initialRoute("test_page")
//                .build(this)
//                .also {
//                    startActivity(it)
//                }

            FlutterActivity.withCachedEngine("my_engine_id")
                .build(this)
                .also {
                    startActivity(it)
                }
        }
        btnBoost.setOnClickListener {
            Intent(this, BoostTestActivity::class.java).also {
                startActivity(it)
            }
        }
    }
}